package day8;

//通过线程模拟病人看病的功能
//第一类病人: 是普通用户 50人 看病时长:500ms
//优先级低一些
//如果普通用户看完了10人优先看完VIP用户再看普通用户
//第二类病人: 是VIP用户 10人 看病时长:1000ms
//优先级会高一些
public class Demo{
    public static void main(String[] args) {
        Thread t1 = new Thread(()->{
            for (int i = 0; i < 10; i++) {
                String name = Thread.currentThread().getName();
                System.out.println("第"+(i+1)+"个"+name+"看病");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        },"VIP用户");

        Thread t2= new Thread(()->{
            for (int i = 0; i < 50; i++) {
                String name = Thread.currentThread().getName();
                System.out.println("第"+(i+1)+"个"+name+"看病");
                try {
                    Thread.sleep(500);
                    if (i == 9)  t1.join();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        },"普通用户");

        t1.setPriority(Thread.MAX_PRIORITY);
        t2.setPriority(Thread.MIN_PRIORITY);
        t1.start();
        t2.start();
    }
}
